#include<iostream>
using namespace std;
void Quicksort(int arr[], int left, int right)
{	

	if (right<left)
	{
		return ;
	}
	int i = left;
	int j = right;
	int pivot = arr[left];
	while (i != j)
	{
		while (arr[j] >=pivot && j > i)
		{
			j--;
		}
		while (arr[i]<=pivot && j>i)
		{
			i++;
		}
		if (i< j)
		{
			int tmp = arr[i];
			arr[i] = arr[j];
			arr[j] = tmp;
		}

	}		
		arr[left]= arr[i];
		arr[i] = pivot;
		Quicksort(arr, left, i - 1);
		Quicksort(arr, i + 1, right);

}

void Disparr(int arr[])
{
	for (int i = 0; i < 5; i++)
	{
		cout << arr[i] << " ";
	}
}

int main()
{
	int arr[5] = { 7,4,8,5,1 };
	Quicksort(arr, 0, 4);
	Disparr(arr);
	
	
	return 0;
}